/*
 * Copyright (c) 2019. ascend 版权所有禁止转载。
 */

package cn.edu.zua.demo18.entity;

import cn.edu.zua.demo18.base.BaseObject;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.*;
import javax.validation.constraints.Email;
import javax.validation.constraints.Max;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * 说明：用户信息表
 *
 * @author ascend
 * 2019/1/30 14:46
 */
@Data
@Accessors(chain = true)
@Entity
@Table(name = "sys_user")
public class SysUser implements BaseObject {
    @Id
    @Column(name = "user_name", updatable = false, nullable = false)
    @Size(min = 0, max = 50)
    private String userName;

    @Column(name = "user_password")
    @Max(256)
    private String userPassword;

    @Column(name = "email")
    @Email
    @Max(50)
    private String email;

    @Column(name = "age")
    @Max(200)
    private Integer age;

    @Column(name = "activated")
    private Boolean activated;

    @Column(name = "activation_key")
    @Max(50)
    private String activationKey;

    @Column(name = "reset_password_key")
    @Max(50)
    private String resetPasswordKey;

    @Column(name = "gmt_created")
    private LocalDateTime gmtCreated;

    @Column(name = "gmt_modified")
    private LocalDateTime gmtModified;

    @ManyToMany
    @JoinTable(
            name = "sys_user_role",
            joinColumns = @JoinColumn(name = "user_name"),
            inverseJoinColumns = @JoinColumn(name = "role_name")
    )
    private Set<SysRole> roleSet;
}
